package com.woniuxy.stage3demo.mapper.lyl;

import com.woniuxy.stage3demo.bean.chenyuxuanBean.StaffBean;
import com.woniuxy.stage3demo.bean.lyl.MailMessageBean;

import com.woniuxy.stage3demo.bean.lyl.StationMessageBean;
import com.woniuxy.stage3demo.pageHelper.PageRequest;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.Date;
import java.util.List;

@Mapper
public interface MailMessageMapper {
    /**
     * 分页查询
     * @param
     * @return
     */
  /*  @Results({
            @Result(id=true,property = "id",column = "id",javaType = Integer.class),
            @Result(property = "sendNums",column = "send_nums",javaType = Integer.class),
            @Result(property = "msgTitle",column = "email_msg_titel",javaType = String.class),
            @Result(property = "msgContent",column = "email_msg_content",javaType = String.class),
            @Result(property = "date",column = "date",javaType = Date.class),
            @Result(property = "delFlag",column = "del_flag",javaType = Integer.class),
            @Result(property = "staff",column = "staff_id",javaType = StaffBean.class,one =
            @One(select = "com.woniuxy.stage3demo.mapper.lyl.StaffMapper.getOneById",fetchType = FetchType.LAZY))
    })*/

    /*@Select("select * from email_message where staffId=0")*/
    List<MailMessageBean> findAllByParams(@Param("p") PageRequest request,@Param("s")MailMessageBean mailMessageBean);
    /**
     * 存储新消息
     * @param mailMessageBean
     */
    @Insert("insert into email_message (email_msg_content,staff_id,date,send_nums,del_flag,email_msg_title) values" +
            "(s.msgContent,s.msgTitle,s.staffBean.id,s.date,s.sendNums,0,s.msgTitle)")
    void saveMailMessageBean(@Param("s") MailMessageBean mailMessageBean);
    /**
     * 删除站内信
     * @param id 站内信编号
     */
    @Update("update email_message set del_flag = 0 where id=#{id}")
    void deleteOneStationMessageBean(@Param("id")Long id);
    /**
     * 条件查询站内信
     * @param emailMsgContent
     * @param
     */
   /* @Results({
            @Result(id=true,property = "id",column = "id",javaType = Integer.class),
            @Result(property = "sendNums",column = "send_nums",javaType = Integer.class),
            @Result(property = "msgTitle",column = "email_msg_titel",javaType = String.class),
            @Result(property = "msgContent",column = "email_msg_content",javaType = String.class),
            @Result(property = "date",column = "date",javaType = Date.class),
            @Result(property = "delFlag",column = "del_flag",javaType = Integer.class),
            @Result(property = "staff",column = "staff_id",javaType = StaffBean.class,one =
            @One(select = "com.woniuxy.stage3demo.mapper.lyl.StaffMapper.getOneById",fetchType = FetchType.LAZY))
    })
    @Select("<script>" +
            "select s.id,s.email_msg_content,staff.id,s.date,s.send_nums,s.del_flag,s.email_msg_title from email_message as s ,staff where " +
            "<if test='emailMsgContent!=null'>" +
            "s.station_msg_title like %#{stationMsgTitle}%," +
            "</if>" +
            "<if test='name!=null'>" +
            "staff.name=#{name}," +
            "</if>" +
            "and del_flag=0"+
            "</script>")
    List<StationMessageBean> selectStationMessageBeanByTitleAndName(PageRequest request,String emailMsgContent,String name );

*/
}
